import apiClient from "../apiClient";
import type {UserInfo, UserToken} from "#/entity";

export interface SignInReq {
    phone: string;
    passwd: string;
}

export interface EditPwdReq {
    new_passwd: string;
    token?: string;
}

export interface EditPwdReq {
    new_passwd: string;
    token?: string;
}

export interface QrCodeReq {
    qrcode_info: any;
    token?: string;
    lng?:string,
    lat?: string,
}


export type SignInRes = UserToken & UserInfo;

export enum UserApi {
    SignIn = "/index.php/minapp/passport/login",
    EditPwd = "/index.php/minapp/passport/change_password",
    CheckQRCode = "/index.php/minapp/Driver_check/check_qr_code",
}

const signIn = (data: SignInReq) => apiClient.post<SignInRes>({url: UserApi.SignIn, data});
const editPwd = (data: EditPwdReq) => apiClient.post({url: `${UserApi.EditPwd}`, data});

const checkQRCode = (data: QrCodeReq) => apiClient.post({url: `${UserApi.CheckQRCode}`, data});

export default {
    signIn,
    editPwd,
    checkQRCode
};
